#include "datamanager.h"
#include <cmath>
#include "settings/settings.h"
DataManager::DataManager(){
	table = new double[(int)(21*M_PI)];
	cTable = new double[(int)(21*M_PI)];
	for(int i=0;i<2*M_PI*10;i++){
		table[i] = std::sin(i/10.0);
		cTable[i] = std::cos(i/10.0);
	}
	int it = Settings::instance()->getSize();
	it*=Settings::instance()->getSize();
	it*=2;
	sqrtTable = new double[it+1];
	for(int i=0;i<=it;i++){
		sqrtTable[i] = sqrt(i);
	}
}
DataManager* DataManager::instance(){
	static DataManager c;
	return &c;
}
DataManager::~DataManager()
{
	delete[] sqrtTable;
	delete[] table;
	delete[] cTable;
}
const double& DataManager::getSin(const double& pos)
{
	return table[(int)(pos*10)];
}
const double& DataManager::getSqrt(const int& pos)
{
	return sqrtTable[pos];
}
const double& DataManager::getCos(const double& pos)
{
	return cTable[(int)(pos*10)];
}
